package cn.lingyangwl.agile.food.core.manager;

import cn.lingyangwl.agile.food.core.mapper.CartMapper;
import cn.lingyangwl.agile.food.model.entity.Cart;
import cn.lingyangwl.agile.food.core.model.rqrs.cart.CartListReq;
import cn.lingyangwl.framework.tool.core.StringUtils;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

/**
 * @author shenguangyang
 */
@Component
public class CartManager extends ServiceImpl<CartMapper, Cart> implements IService<Cart> {

    public List<Cart> listCart(CartListReq req) {
        if (StringUtils.isEmpty(req.getCartType())) {
            return Collections.emptyList();
        }
        return this.list(Cart.lqw().eq(Cart::getCartType, req.getCartType()));
    }
}
